<template>
 <view class="">
 	
 	<view class="exhibit" v-if="Collection.length != 0">
 	 <view class="Collection" >
 	 	<view :class="!GongGestate? 'Collection_item':'CollectionNew_item'" >
 	 		<block v-for="(item,index) in Collection" :key="index">
 	 			<view class="Collection_img"  >
 	 				<view class="" >
 	 					<image :src="item.user_product_snap.product_snap.cover"
 	 					:class="!GongGestate? 'Collection_image':'CollectionNew_image'"></image>
 	 						<!-- <u-lazy-load :image="item.user_product_snap.product_snap.cover" :loading-img="loadingImg" border-radius="24" style="width: 240rpx;height: 240rpx;min-height: 240rpx;" ></u-lazy-load> -->
 	 				</view>	
 	 					<view  class="Collection_right">
 	 						<view class="Collection_right_text">{{item.user_product_snap.product_snap.name}}</view>
 	 						<view class="Collection_right_wrapper">
 	 							<image src="/static/collect_icon.png" style="width: 44rpx;height: 44rpx;" class="item_farstimg" ></image>
 	 							<text  class="item_center">{{item.user_product_snap.no}}</text>
 	 						</view>
 	 						<view  style="display: flex;align-items:center;">
 	 							<image :src="item.user_product_snap.product_snap.creator_avatar" style="width: 34rpx;height: 34rpx;margin-right: 10rpx;border-radius: 50rpx;" ></image>
 	 							<view class="Collection_right_bottom">{{item.user_product_snap.product_snap.creator_name}}</view>
 	 						</view>
 	 					</view>
            <view class="itemnum">x{{item.num}}</view>
 	 			</view>
 	 		</block>
 	 	</view>
 	 </view>
 	  </view>
	  <empty :show.sync="Collection.length == 0 && pagestate"></empty>
 	</view>
 	
</template>

<script>
import api from "@/api/api.js";
import tip from "@/utils/tip.js";
import moment from "moment";
import { isLogin } from "@/utils/auth.js";
import empty from "@/components/empty/empty";
export default {
  components: {
    empty,
  },
  data() {
    return {
      page: 1,
      limit: 10,
      pagestate: false,
      GongGestate: false,
      Collection: [],
    };
  },
  onLoad() {},
  onShow() {
    this.getproducts();
  },
  computed: {
    is_Coming_soon() {
      return (time) => {
        return moment(time).diff(moment(), "second") > 0;
      };
    },
  },
  methods: {
    async toCollection(itme, index) {
      uni.navigateTo({
        url: `../../pages/collect_record/collect_record?user_product_id=${this.Collection[index].user_product_snap.id}`,
      });
    },
    GongGe() {
      this.GongGestate = !this.GongGestate;
    },
    async getproducts() {
      let res = await api.mergeLogs({
        query: {
          page: this.page,
        },
      });
      uni.stopPullDownRefresh();
      if (res.code == 0) {
        res.data.forEach((el) => {
          el.user_product_snap = JSON.parse(el.user_product_snap);
          Array.isArray(el.user_product_snap)?el.user_product_snap = el.user_product_snap[0]:''
          el.user_product_snap.product_snap = JSON.parse(el.user_product_snap.product_snap);
        });

        if (this.page == 1) {
          if (res.data.length > 0) {
            this.Collection = res.data;
          } else {
            this.pagestate = true;
          }
        } else {
          if (res.data.length > 0) {
            this.Collection = [...this.Collection, ...res.data];
          }
        }
      }
    },

    onReachBottom() {
      this.page++;
      this.getproducts();
    },
    // 页面下拉刷新
    onPullDownRefresh() {
      this.page = 1;
      this.getproducts();
    },
  },
};
</script>

<style>
page {
  background-color: #0c0d0d;
}
</style>

<style lang="scss" scoped>
@import "../../style/yuanchuang.scss";
.content {
  width: 690rpx;
  font-family: PingFangSC-Regular, PingFang SC;
  padding: 0 30rpx 0 30rpx;
  background: $bg-color1;

  // background-image: url(../../static/index_bg.png);
  // background-repeat: no-repeat;
  // background-size: 100% 510rpx;
}

.search {
  width: 690rpx;
  height: 88rpx;
  display: flex;
  align-items: center;
  justify-content: space-between;
  &_logo {
    width: 192rpx;
    height: 54rpx;
  }
  &_icon {
    width: 40rpx;
    height: 40rpx;
  }
}
.top {
  width: 690rpx;
  height: 280rpx;
  background: black;
  border-radius: 24rpx;
  &_image1 {
    width: 690rpx;
    height: 280rpx;
  }
}
.u-tabs_line {
  display: flex;
  position: relative;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  .u-tabs_wrapper {
    width: 70%;
  }
}
.exhibit {
  overflow: hidden;
  &_item {
    width: 690rpx;
    height: 904rpx;
    background: #1d1d28;
    border-radius: 36rpx;
    &_wrapper {
      position: relative;
      width: 690rpx;
      height: 690rpx;
    }
    &_timer {
      z-index: 1;
      position: absolute;
      top: 26rpx;
      left: 26rpx;

      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 20rpx;
      // width: 408rpx;
      height: 60rpx;
      background: #000000;
      border-radius: 30rpx;
      // opacity: 0.46;
      background-color: rgba(0, 0, 0, 0.46);
    }
    &_timerIcon {
      width: 32rpx;
      height: 32rpx;
    }
    &_timerText {
      margin-left: 8rpx;
      font-size: 28rpx;
      font-weight: 400;
      color: #f78623;
      line-height: 40rpx;
      // opacity: 0.46;
    }
    &_sale1 {
    }
    &_sale2 {
      margin-left: 12rpx;
    }
    &_goodsImage {
      border-radius: 36rpx;
      width: 690rpx;
      height: 690rpx;
    }
    &_bottom {
      display: flex;
      align-items: center;
      justify-content: space-between;
    }
    &_left {
      margin: 30rpx 0 0 30rpx;
    }
    &_right {
      height: 138rpx;
      margin: 46rpx 30rpx 0 0;
    }
    &_first {
      width: 400rpx;
      height: 44rpx;
      font-size: 32rpx;
      font-weight: 500;
      color: #ffffff;
      line-height: 44rpx;

      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    &_second {
      display: flex;
      align-items: center;

      margin: 20rpx 0;
      font-size: 24rpx;
      font-weight: 400;
      color: #ffffff;
      line-height: 34rpx;

      // width: 202rpx;
      height: 34rpx;
      border-radius: 4rpx;
    }
    &_limited {
      // width: 76rpx;
      padding: 0 14rpx;
      height: 34rpx;
      background: linear-gradient(130deg, #f78623 0%, #d5280a 100%);
      border-radius: 4rpx;
      text-align: center;
    }
    &_inStock {
      padding: 0 14rpx;
      // margin-left: 10rpx;
      font-size: 24rpx;
      font-weight: 400;
      color: #ffffff;
      line-height: 34rpx;
      background: #262934;
    }
    &_third {
      display: flex;
      align-items: center;

      font-size: 26rpx;
      font-weight: 500;
      color: #ffffff;
      line-height: 36rpx;
    }
    &_avatar {
      border-radius: 50%;
      margin-right: 8rpx;
      width: 36rpx;
      height: 36rpx;
    }
    &_username {
      font-size: 26rpx;
      font-weight: 500;
      color: #ffffff;
      line-height: 36rpx;
    }
    &_button {
      margin-left: calc(100% - 116rpx);
      width: 116rpx;
      height: 56rpx;
      border-radius: 28rpx;
      text-align: center;

      font-size: 28rpx;
      font-weight: 400;
      line-height: 56rpx;

      color: $text-color4;
      background: $button;
      background-repeat: no-repeat;
      background-size: 100%;
    }
    &_buttonGray {
      margin-left: calc(100% - 116rpx);
      width: 116rpx;
      height: 56rpx;
      background: #999999;
      border-radius: 28rpx;
      text-align: center;

      font-size: 28rpx;
      font-weight: 400;
      color: #ffffff;
      line-height: 56rpx;
    }
    &_price {
      margin-top: 34rpx;
      font-size: 40rpx;
      font-family: SFPro-Bold, SFPro;
      font-weight: bold;
      color: #ffffff;
      line-height: 48rpx;
    }
  }
  &_item:not(:first-child) {
    margin-top: 30rpx;
  }
  &_item:last-child {
    margin-bottom: 30rpx;
  }
}
.Collection {
  color: #ffffff;
  font-size: 32rpx;
  margin: 40rpx 30rpx;
  // background-color: $bg-color1;
}
.Collection_top {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20rpx;
}
.CollectionNew_item {
  display: flex;
  justify-content: space-between;
  flex-direction: row;
  align-items: flex-start;
  flex-wrap: wrap;

  /* align-items: flex-start;
		margin:30rpx 0; */
  .Collection_img {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    // background-color: #1c1e27;
    border-radius: 15rpx;
    margin: 15rpx 0 15rpx 0;
    width: 48%;
    height: 540rpx;

    background-image: url("/static/backgroundNew.png");
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;

    .CollectionNew_image {
      width: 330rpx;
      height: 330rpx;
      border-radius: 24rpx;
    }

    .Collection_right {
      margin-left: 30rpx;
      padding: 20rpx 0;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      align-items: flex-start;
      // height: 200rpx;
      .Collection_right_text {
        font-size: 28rpx;
        // padding-top: 15rpx;
        overflow: hidden;
        -webkit-line-clamp: 1;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
      }
      .Collection_right_bottom {
        font-size: 24rpx;

        width: 320rpx;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
    }
    .itemnum{
      flex: 1;
      text-align: end;
    }
  }
}
.Collection_item {
  display: flex;
  justify-content: space-between;
  flex-direction: column;
  align-items: flex-start;

  /* align-items: flex-start;
		margin:30rpx 0; */
  .Collection_img {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    /* border: 2rpx solid rgba(255,255,255,0.1); */
    // background-color: #1c1e27;
    /* padding-bottom: 30rpx; */
    /* border-radius: 80rpx 80rpx 24rpx 24rpx; */
    border-radius: 15rpx;
    margin: 15rpx 0 15rpx 0;
    width: 100%;

    background-image: url("/static/background.png");
    background-repeat: no-repeat;
    background-position: center;
    /* background-attachment: fixed; */
    background-size: cover;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    .Collection_image {
      width: 240rpx;
      height: 240rpx;
      border-radius: 24rpx;
    }

    .Collection_right {
      margin-left: 30rpx;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      height: 200rpx;
      .Collection_right_wrapper{
        display: flex;
        align-items: center;
      }
      .Collection_right_text {
        font-size: 28rpx;
        // padding-top: 15rpx;

        width: 300rpx;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        // -webkit-line-clamp: 1;
        // display: -webkit-box;
        // -webkit-box-orient: vertical;
      }
      .Collection_right_bottom {
        font-size: 24rpx;

        width: 320rpx;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
    }
  }
}
.item_center {
  position: relative;
  left: -30rpx;
  font-size: 20rpx;
  padding: 0rpx 10rpx 5rpx 26rpx;
  border-radius: 17rpx;
  color: $text-color4;
  background-image: $gradient1;

  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item_farstimg {
  z-index: 2;
  position: relative;
  // top: 15rpx;
  left: -2rpx;
}
</style>
